﻿<%@ WebHandler Language="C#" Class="_2_IncreaseValue" %>

using System;
using System.Web;

public class _2_IncreaseValue : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";

        string number = context.Request["number"];
        string ispostback = context.Request["ispostback"];  //通过表单得到的数据都是字符串类型的
        if (ispostback == "true")  //说明点击自增进来的
        {
            int i = Convert.ToInt32(number);
            i++;
            number = i.ToString();
        }
        else
        {
            number = "0";
        }
        
        string path = context.Server.MapPath("2_IncreaseValue.htm");
        string content = System.IO.File.ReadAllText(path);
        content  = content.Replace("@value", number);
        context.Response.Write(content);
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}